<?php
// *** Tangra (Application Framework and Tools for PHP)
//  $Id$
//


require_once(TANGRA_MAIN_DIR.'interfaces/i_tple.class.php');


class Tple_Smarty extends Tangra_Class implements I_Tple {
	private $smarty;

	function __construct() {
		$old_err_rep = error_reporting(SYSTEM_ERROR_REPORTING_PHP4_LIBS);
		$this->smarty = new Smarty();
		error_reporting($old_err_rep);
	}


	public function display($tpl, $cache_id = null, $compile_id = null) {
		$old_err_rep = error_reporting(SYSTEM_ERROR_REPORTING_PHP4_LIBS);
		$this->smarty->display($tpl, $cache_id, $compile_id);
		error_reporting($old_err_rep);
	}


	public function fetch($tpl, $cache_id = null, $compile_id = null, $display = false) {
		$old_err_rep = error_reporting(SYSTEM_ERROR_REPORTING_PHP4_LIBS);
		$ret = $this->smarty->fetch($tpl, $cache_id, $compile_id, $display);
		error_reporting($old_err_rep);

		return $ret;
	}


	public function assign($tpl_var, $value = null) {
		$old_err_rep = error_reporting(SYSTEM_ERROR_REPORTING_PHP4_LIBS);
		$this->smarty->assign($tpl_var, $value);
		error_reporting($old_err_rep);
	}


	public function set_tpl_dir($tpl_dir) {
		$this->smarty->template_dir = $tpl_dir;
	}


	public function get_tpl_dir() {
		return $this->smarty->template_dir;
	}


	public function set_compile_dir($compile_dir) {
		$this->smarty->compile_dir = $compile_dir;
	}


	public function set_cache_dir($cache_dir) {
		$this->smarty->cache_dir = $cache_dir;
	}


	public function set_caching($caching) {
		$this->smarty->caching = $caching;
	}


	public function set_delimiters($left, $right) {
		$this->smarty->left_delimiter = $left;
		$this->smarty->right_delimiter= $right;
	}


	public function set_additional_plugins_directories($dir_arr) {
		foreach($dir_arr as $dir) {
			$this->smarty->plugins_dir[] = $dir;
		}
	}
}


